Refactored query string parse.