Refactor Transaction and Dataset

Replaces #231 

I rebased against master where some recent merged had created conflicts, fixed them up, and squashed.