Fix speed regression for ambiguity codes.
Add comments.