improved node handling with id reuse