Reorganized the exports

Reverted to the old way of exports on top and function declarations
after that. Updated the docblocks to reflect this way of structuring
modules in node.