Added documentation and ensured long running threads stay alive