Added a few comments.
Refactoring darwin thread code for better shutdown handlers.