more marshalling refactor