added in_group functionality, some code cleanup