Fix stack overflow and add support for 64 bit offsets