Moved everything to a thread