Check for A==0 / B==0.

Unlike #9, this PR does *not* include Danny's other improvements. It just has the group-element check.

(note that this means it fails tests every once in a while, because of the padding bugs that Danny's Buffer-ification fixed).

cc @ckarlof