Hotfix: Codeword extraction

There were critical errors in the code for extracting type and length
from the first codeword; they have been corrected.  Other minor changes.