fix statemap creation and update references, fix caching
fix history traversing