Fix localstorage and PreferenceManager
Abstract away Window API's