fix crash when removing single layer