Fixed offsets calculation. First good result :)