Export functionality

I'm starting to work on making exporting happen. Not at all ready to merge - I'm just curious what you think.
Please change that boolean to an enum. I can't tell from the call site what it means.