Improved collision detection and prevented walking off the map!