Quite a lot of refactoring here but no major changes really.