Issue14

Pushed a bunch more code for #14.

These changes should make #21 & #22 easier.