Preload groups, SQL bugfixes

SQL had some issues with unique keys that prevented users and groups
from having the same name, and some other stuff.