fix flaws revealed by not working in chromium