partly done, ready for merging a few files back to master.