Merge "Add logic for calculating offsets during writing"
am: 4e0ccc92ec

Change-Id: I8ff1fc8c67c901c88ca8281353efacd78ad87d10