Minor code improvements in lib/index.js