Fix import errors in browser mode. Fixes #1117 and fixes #1118