Cleanup all code for consistency, and clarity.

I don't want the exports to be above private functions. Please restore previous