Attempt to fix occasional crash on startup.

(Ico's fixes.)