Tidied up plus bugfixing