Refactor help functions into utils file.

This makes the core code easier to read and makes the utils
easier to maintain.

Some of these util scripts could probably be pulled into an
external library