further tidies of the code