More tidying and re-factoring.