Massive hack to get CTR mode working (uses globals and hard-wiring).

Needs a total cleanup.