Tweaked a few things for speed. I think more could still be done. t_getconsts.py accounts for ~50% of the runtime.