Fixed a crash when app becomes active again