Some fixes

Hi Dustin,

Sending you a PR so you can see all my latest changes. Can you run your eye over them, and check you are happy with them? In particular, you'll see I now url decode the hg/git mapping file we receive from the insert requests...

Thanks,
Pete