Moved index.js stuff to lib/ to function as plugins