Better exception throwing.
Remove unnecessary encode/decode before querying.