semantic: fix possible crashes