Fixes race condition in resources

This is accomplished by changing group_id, an integer field,
to res_group, a foreign key to a new model called ResourceGroup.