Updated thread handling and fixed some issues with the data collect
thread