Fixed problem with app crashing on pausing or switching apps