fixes for typo in partial mar creation, moves helper methods to the top