Mostly tidying up white space and comments. Also rearranged