Fixed memory leak and improper erasing of std::set elements

Change-Id: Ie9acb713ef78cff172646cd09437918e52916b18
Merge topic 'fix_append_filter' into master

1ae1b522 Fixed memory leak and improper erasing of std::set elements