Fixed the issue where mainController is writing serially while datacollector may also write at the same time.  This is a working version