Write mod utility functions

Note: untested