Properly handle reassigned handles.
Move node flags into the node class.
Add clear_sparse function.