Added better heap implementation.