Handle databases with matching object names somewhat better

Maybe a pull request is easier to deal with. The biggest part of these changes was to refactor the %GOAT hash a whole bunch