Fix globals in wsapi.js that seemed to be created unintentionally and fix the modules that depended on implicit globals