Part 3 of state file bugfixes