Tidy up code a bit