Added Ptr class to handle pointer abstraction. Patch now works properly (ish)