Move the receipt fixing logic into a separate file ( the header remains polluted ). Removing also as many pointers as I can.