Tidied up code base