Heap removal added. Variable names made more specific in places.