Fixed the crashes introduced by the last commit