WebGL and misc memory optimizations

P.S. to turn the WebGL on use #webgl=true, e.g. https://bug793542.bugzilla.mozilla.org/attachment.cgi?id=663870#pdfBug=Stats&webgl=true