Refactoring collision detection again.