Additional refactoring; fix deferred hint resolution; fix a compareByScope bug