Fix midpoint displacement bug