Thread module: bug-fixes and implementation reorganization.
Added Autotools build system.