One final major refactor/tidy up.