MAJOR Tidied up loose ends so code more resuable