refactored some cref modification code into its own class gh-77