Added atom as a generic statemanagement construct. Inspired by Clojure atoms