Stuck mainloop into its own thread and stuff.