Added more comments, utilize heap