Working version of StateMonitor (all recorded variables are stored to files)