Corrected some bugs related to not finally implemented system for query handling