Add basic exports. Remove some global usage. Minor cleanup.