Update to work on node 11

The error code for ENOENT changed from 34 to -2 from node 10 to node 11.
I updated that, I also did a few minor refactors.