Fix devices relationship to groups