fixes for grouping; initialization for more efficiency