Fleshed out more of the thread-handling