Pg cleanup

Added a bunch of cleanup to the core postgres database class. Fixed up some of the database storage concerns for streaming out to file, linking file into the database via path, reading back out, etc.