fixed a bug in collision detection. added grid.

grid needs serious debugging.