fix json typo
fix error debugging
rework context map:

- make it thread safe by adding lock
- encapsulate in object