Fixed an issue where nodes were not destroyed properly.