Fixing index.js and a minor issue with the api