Patches to correct termination bug.