Fix generalization bugs