refactored mergeability-checking code.