Putting things into right place

Just moved some of the stuff into a header file to tidy things up