added close-hook and some more logging; rev 1.2.6