Fixed pseudo-bugs on state restoration.