Several updates. Added multiple group handling.