[CS] Organize code into namespaces

Fixes bugs in db fns as well.
Merge pull request #1 from turbovote/organization

[CS] Organize code into namespaces