Added a method to protect and restore sets. however, doesn't work for nested sets. Might be inefficient.