Fix logging bugs