Fixed URL building and escape/encoding errors.

..oh lord!