auto rezolve works.  Some of this is a bit untidy to be honest - might need a refactor.