Lots of work to rewrite  gen_encode.pl as q-mgr.py