Lots of refactoring 5
Lots of refactoring 6
tidyups
more changes