Ongoing gradual refactor / code cleanup / modularisation