Changes to reduce the number of nodes stored in the heap.

This change will maintain the heap size to O(N) and will not add duplicate entries
to the heap. The key to the heap is also a int and not an list.