Subgroup subexpression fix

These fixes close #228 for me and the barrelcortex example (#227) now also works when using subgroups. From my side: ready to merge