Tidied up code & comments