(a) It is defective, within the meaning of section 170.35; or
(b) The defendant has received immunity from prosecution for the offense charged, pursuant to sections 50.20 or 190.40; or
(c) The prosecution is barred by reason of a previous prosecution, pursuant to section 40.20; or
(d) The prosecution is untimely, pursuant to section 30.10; or
(e) The defendant has been denied the right to a speedy trial; or
(f) There exists some other jurisdictional or legal impediment to conviction of the defendant for the offense charged; or
(g) Dismissal is required in furtherance of justice, within the meaning of section 170.40. 2. A motion pursuant to this section, except a motion pursuant to paragraph (e) of subdivision one, should be made within the period provided by section 255.20. A motion made pursuant to paragraph (e) of subdivision one should be made prior to the commencement of trial or entry of a plea of guilty. 3. Upon the motion, a defendant who is in a position adequately to raise more than one ground in support thereof should raise every such ground upon which he intends to challenge the accusatory instrument. A subsequent motion based upon such a ground not so raised may be summarily denied, although the court, in the interest of justice and for good cause shown, may in its discretion entertain and dispose of such a motion on the merits notwithstanding. 4. After arraignment upon an information, a simplified information, a prosecutor's information or misdemeanor complaint on a charge of prostitution pursuant to section 230.00 of the penal law or loitering for the purposes of prostitution pursuant to subdivision two of section 240.37 of the penal law, provided that the person does not stand charged with loitering for the purpose of patronizing a prostitute, where such offense allegedly occurred when the person was sixteen or seventeen years of age, the local criminal court may dismiss such charge in its discretion in the interest of justice on the ground that a defendant participated in services provided to him or her.