Make name uniqueness system-wide

The data model really needs to be cleaned up, but this change should
provide a capable enough solution for now.
Fix problem with PostGres group by

The group_by call should not be necessary since only one result should
ever be returned.