Updated State class to be thread-safe