Refactoring and tidying up _helpers/util

Clean up old lint and move some functions to pycodeexport.