mostly tidying, light refactoring.