Update global.js

documentation and code improvements