refactored for query history a bit for cleanup; history takes into account data db version; ui cleanup TODO