Fix problem on entity and dynamic groups. closes #2367