Fix input gates D and B bug