Threaded fix, and logic cleanup.