Fixed a crash caused by not removing observer