Cleaned up some stuff - removing commented code, added global for shutting down threads that would run infinitely otherwise