Smaller fixes + backported fix from W3C version