I didn't really give the code a good look but my first was at the array and it started with 1, normally a array starts at 0, and I saw the code:

for( i = 1; i < limit; i++ ) wich I think may be a...