Fix #TANAL-44: move cleanup to the end again, was removing :atom too early