Fixed crash on startup in some cases