Fix stdin/out close, minor logging changes