Cleaned up the code; still can't figure out the collision detection.