Fixed bugs in database driver.