added some node modules for compatibility reasons
cleaned up code and added basic error checking