Unselect layer in catalogtree when removed in layer manager
Use function to access element
Refactoring based on comments
Adding comment