fix history flattening