Port patches and fixes over from node