redid the resolution code

it now is broken up into sensible files, the code is written in an
idiomatic and stylistically proper way, and it doesn't depend on lots of
buried mutable state. this will (hopefully) allow things to be debugged
easily.