Tidied up code, removed old remnants