More refactoring + precise collision detection