Clean and consolidate export code #190
New export code fixes "interaction of tie splitting and dynamic contexts" issue

TODO finish new export

Fixes #216