Big overhaul to 637 paper code