Clean up unused nodes