Make exports consitent.

Previously, the exports were somewhat random with some files declaring
local variables then immediately exporting them, and others simply
doing the work needed in the export itself.
Merge pull request #2915 from rjackson/make-exports-consistent

Make exports more consistent.