Add some anti-crash checking.