Changed database handler

Changed: made the handler public
Changed: made sure connection is closed at the end of the master
Removed: deleted non-error printfs