Tidied up code with trivial changes