Fix detached head state