Shift docdown function to index.js and other bugfixes