Pull in updates, bug fixes for pattern.py from port_ids branch.