Minor cleanups and added more traceback to debug logging.