Added Logging, and ability to select Database
a few bug fixes