This is what it was doing before, but there were issues because the class was getting instantiated inside a thread, which didn't work well. I have to think again about whether there is a way to do it and make sure the class is instantiated in the main thread.