Fixed logical errors in some Database APIs