some tidying and rationalisation of parsing and formatting, plus further progress on CORS types