more refactoring of Result and such