Fixes issue with switching layers