Refactors the conflict detection code.