Modified PersistantData to work in agent AND device code