Added better checking for localStorage existence
Documented use of localStorage