Fixed some NPE issues with task history