Fixing region algorithms and tests.