Fix crashes when changing files