Finished up core code for MaskRuleEngine.