Bug fixes, more debugging output