Added inline comments to log writing function and clean generated stuff.