Bugfix midpoint calculation