debug logging + minor fixes