Refactoring
Collision detection added.