Fix for issue #4730 - stacktrace when deferenencing a non-existent group

Hopefully this time my pull request is OK. I apologize for the previous mess.