replace ENCODING_URL with ENCODING_QUERY
clean up code style, fix some docblocks and other stuff