This looks very fragile. Could we avoid this hard-coding, for example via a regexp substitution?