Fixing javascript to allow settings changes while reading, updating state with more options