More documentation, created utility function script

Added documentation for more functions, created a script to contain
utility functions (stuff less than around ten lines that's not
user-facing).