Various refactoring.

Resolve now uses ClassTags instead of TypeTag (race conditions, renamed to resolveUnsafe).
Backported tweaks from feature branch.

TODO: more cleanup required