improved readability of replace statements

It is a little strange that for i=0 the replace is 'eax'->'ea0[0]' etc and for i>0 'g%seax'->'ea%s[0]' etc. why not all in the form 'g%seax'->'ea%s[0]'? then could just iterate over all grid rather than explicitely setting i=0 after setting i>0. This took me a while to figure out when debugging the code.