Merge upstream changes and update to use nan