#4571: Fixed memory error.

- Was removing node before converted one created, so it couldn't be
created out of nothing.
- Minor code edit.