add persist package
1. merge state into main package
2. fix quite a lot compile errors