Some fixes to avoid problems on startup (issue #19).