Fix broken maths when extending in certain directions.