Fix #1040: panic on start up

That's what I did. The pr is merged into master.