Fixing some crashes