Don't 404 with hex-encoded characters in the url

Also some minor changes for style and to reduce some allocations.