Updating examples to the new API
(cherry picked from commit 13fbd7d18209981e74dc2d98899019f84da7080c)
Updating State example to use the new APIs
(cherry picked from commit e0f999d9d5b46c536f6a67052cea22717a2c2dc6)