Feature/fix offset calculations