Minor changes to data logging code to increase reliability