Added the heap functionality to aid the scheduler.