Dominic: reorganise code into separate modules