Add comments for document.js + some cleaning -- partial