convert state_store from gen_server to simple functions, implementing a minimal db layer