Adding support for NPM and refactored things a little to accomodate that change.