Refactored resolve routine.