Fix for #252 with broken logic on saving Layer.