- fix some concurrency bugs
- encapsulate inner data structure