several fixes to query-db-history