Reorganized libraries and added postgres base classes