Fixed issues with node deletion and rearrangement.