performance optimizations for write speed and fix to recover thread exce...

...eding issue with a configured wait