Fix some bugs in gencat U computation.

* gencat.generate had some bugs found by Viktoria Asboth.