Basic save state functionality, no loading.

Declaring vars in block scope is inconsistent with the semantics of the language, so probably good to avoid. Using a function form lodash would avoid this issue.