Restructured logging code.