Fixed totally wrong calculation of relative grid locations