Add some protection against strange crash.
Cleanup.