Refactored collision detection out into its own source file.