Refactoring; tidying up