Reworked some calculations of coordinates.