Fix crash with layer model