bug fix, and some debug messages
(#420)