Tidy up the code