Added localStorage support and other fixes.