Refactor auto resolve code.