Fix possible crash.
Simplifying some code.