refactored database code to use callbacks
removed pooling feature. This is better implemented in a higher level.