Tidy up code layout