Tidy up and clean up service builder code
Work in progress, questions raised as TODOs.