Added support for groups
Various fixes/improvements