Add opening/locking/stating of state file