Code cleanup and collision detection (terrain).