Tidy up & comment code