Fix crash on startup under certain conditions.