changed struct for heap elements and memory management