Complete rewrite so that it works on Chrome for Android