Minor bug fixes and removal of debug output