Fixed termination issues