Updated thread checks and added in-line documentation.
Updated thread checks and added in-line documentation.