Final go through of code, tidied up and commented what was missing