Split up collision detection code into separate file