More error checking and added in package.json for npm.