Massively refactored, added collision detection