Fixed bugs with layer toggle