slight changes (performance in c++ code and deleting groups)