Fix crashes because of reference to resource not existing yet