bugfixes and improved groups handling