Query and error improvements