Fixed some bugs in Heap and Scheduler