Fixed js errors, mostly dealing with getElements from the document.