Fix a warning and a possible crash