Cleaning up. Moving functions to util namespace.
Simplify action code.
Move REST stuff to util namespace.