Random saving of the settings file is likely to cause trouble. Have you checked that there are no weird interactions here?