Fixed issue with collision detection logic.