Tidy up code to start work on dependancy injection