Clean and consolidate export code #190

Localized local functions...