Fixed heap code, cleanups-r-us