Fix some bugs in the references panel
Created by: chrismwendt
I ran into some JavaScript errors when returning external refs from the new Go extension and I managed to change the grouping code enough to avoid these errors, but I admit I do not understand it very well and I may have introduced other problems. @sqs Can you take a look?