Tidying up and re-factoring