Working version. Good state updates. Some error notifications. Going to get rid of a few global variables.