fix logfile, rearrange matrix