Static analysis showed some unused variables and imports, and running the code in Python 3.9 revealed a few invalid escapes (previous versions of Python silently "fixed" these, so the code change here will not affect the results).