Added support of multiple groups

Should solve #615