minor changes on template defs and unused code.
Changed concurrency management in reader and processor threads to close
cleanly on disconnect.
Changed to test disconnect.