Fix some writing errors