Major bugfixes in the boundary function optimizer.