Fixed issues with deleting layer.