logfile opening/closing fixes