more refactoring of Unmarshal