Partially implemented offset calculation.
This commit is in order to be able to merge to the master branch
Merge from branch offsets to master