Fixed crashes that occured during orientation changes etc.