added proper key, value parsing for query string parts.

Also, refactored query string extraction to two lines.