Moved helper code

Moved helper code to it's own file. This will make organisation a lot
easier.