more fixes and more debugging code