Moved helper functions into their own module. More clean up.