Fixes for various crashes