some tweaks, plus debugging code