1540 state restoration

@ysahnpark, @mlippert and @abilleb ... please take a look and code review if you don't mind.  Especially considering this is supposed to go out the door next week, some extra eyes on it would put me at ease.