fixed a few rather anoying crashes