Added state storage and retrieval functions