fix crash when localstorage is empty

also, promote save topic to top-level argument.