Some restructuring
Tidied up