fixed write_mean_groups() and collapse_groups() to work with new architecture (id numbers, more info from IDL)