Reduce number of global variables used

This is the first step to make the exporter more testable.