Fixed most ApplicationState crashses