fixes #4 and fixes #3.  I fixed #4 by delegating all the resolution work to a resolve() function.