Tidy up code in line with coding guidelines