Various fixes to thread handling and documentation updates.