part 1 of huge refactor work to tidy things up