Fixed some encoding problems

Fixed some problems with character encoding and escaping in URL requests and responses.
Some problems still remain and need to be looked further into.