Rewrote open/close to use procedural rules, and better rule naming style.