Fix concurrency bug
Some minor improvments