Refactor State to be 100% thread safe