Fix a bug in beta reduction.