finalized Query interface + general cleanup