Some tidy up code