Added mode switch

@xliiv please review.