better error handling, add warning display, query speedup