Fixes the crash when activities are reloaded

Thanks to @FlashYoshi for reporting the bug :)