Refactoring and tidying up.