Refactor collision handling.