Fix second degree kernel generation.
part of #190.