Refactors collision resolving code