Relocated MarshalHelper and small refactorings.