Fix offset calculation.