Some cleanups of raw reversed code to avoid some bad memory reads and clarify code