Cleaned up writing to logs