fixed a bug which made the game crash if the width of the grid was greater than the unit count, also fixed some other things.