Added query capability. Refactored common to handle responses more uniformly