added QUERY_STRING_ key and fixed line breaks to Unix style

This brings in code from @biegel's branch with a couple of minor changes.