Apparently some operations can only be done on the main thread.