Changed: optimized collision detection, refactored a lot of code