Fix bug causing an exception when a new project is opened