Use state memory instead of mutexes