Some changes from dom and me.
My changes to prep
my changes to impl
Pretty much final. Incorporated Alastair's feedback