Changed states to use sinks and sources
Map of state objects implemented