Fix problem with crash on second open attempt