fixed parsing url with weird encoding. Closes #1
split main app file