- fixed TRICKY bug that makes XtDisplay core dumps when called with a gadget.
  Use XtDisplayOfObject that wirks for gadgets, too.
- replaced global vars with global rec
- added the localloop function
