fix possible crash when modes are set