Changed heap indexing to start from zero