removing possible memory leaks in collecting the results from collections: set, map, list.
correction of some mistakes for the previous commit.
Merge pull request #26 from jacekkasprzak/memory_leaks

Memory leaks