Bugfix: use localStorage instead of global variables