Add logging, change thread env isolation