Refactor database methods into server.
Code review fixes.
Fix leaky shard creation.
Merge pull request #1261 from influxdb/refactor

WIP: Refactor database methods into server