Separate threads and other assorted cleanup