Fix bug with restoring offset