foreach and if/else bug fixes

The system didn't handle loops where the object was null or had 0
elements in the correct way. Also, there was a slight bug where the
go_to commands were changing the token iterator to the wrong place, but
this has been fixed. Things are working much, much more smoothly now.