Collision detection works now, thanks to friends. Cleaned up the code too.