Complete rewrite of the error code generation script. It now runs as a single