Fixing crash related to reloading of layers during frame changes