Upstream merge
Fixed history corruption caused by #1