Small refactor, sample offset calculating.
Implemented local offset calculating and byte count calculating.