Renamed variable from offset to addr
Major code refactoring