fixed bugs and added save session state with queryobject