The browser opening code is a bit clunky. It needs reworking, or perhaps use this library: https://github.com/Shinmera/open-with