cleanup and bugfix index.js