Added Database handler
Switched to batch processing of queries