Adding state module and state system. Closes #1