bug fixes and more debugging info