added url data encoding and some tweaks