Added support for polygon shaped regions, not just rectangular