Broken many things in trying to implement multithreading- will fix later.