Graph resolve

This incorporates previous bugfixes by @alexcrichton that are still stuck in bors.