Changed from using atoms to refs, and added a stateFunctions file with lotsa cool functions