(a) On Court’s Own Motion. Subject to the defendant’s right to a severance under Rule 14, the court may order two or more indictments or informations or both to be tried together if the offenses, and the defendants, if there is more than one, could have been joined in a single indictment or information. (b) On Motion of Defendant; Related Offenses.(1) On motion of a defendant, two or more related offenses charged against him in separate indictments or informations shall be tried together unless the court finds that the ends of justice would thereby be defeated because the prosecuting attorney does not have sufficient evidence to warrant trying one or more of such offenses at that time or for some other reason. A defendant’s failure to so move constitutes a waiver of any right of joinder as to related offenses with which the defendant knew he was charged. (2) A defendant who has been tried for one offense may thereafter move to dismiss a charge for a related offense, unless a motion for joinder of these offenses was previously denied or the right of joinder was waived as provided in paragraph (1) of this subdivision. The motion to dismiss must be made prior to the second trial, and should be granted unless the court determines that because the prosecuting attorney did not have sufficient evidence to warrant trying this offense at the time of the first trial, or for some other reason, the ends of justice would be defeated if the motion were granted. (3) Entry of a plea of guilty or nolo contendere to one offense does not bar the subsequent prosecution of a related offense. A defendant may enter a plea of guilty or nolo contendere on the basis of a plea agreement in which the prosecuting attorney agrees to seek or not to oppose dismissal of other related charges or not to prosecute other potential related charges. (4) Two or more offenses are related offenses for purposes of this rule, if they are within the jurisdiction and venue of the same court and are based on the same conduct or arise from the same criminal episode. (c) Procedure. When offenses or defendants separately charged are tried together under this rule, the procedure shall be the same as if the prosecution were under a single indictment or information.