Refactored offset handling.