Many improvements to parsing, validation and url-encoding