Some code tidy up