Improve extruded polygon and wall performance.

This PR only slightly improves the performance. A few percent here and there but not enough to mention numbers. Most of this PR is removing temporary object creation by using scratch variables.
Unit tests and developer errors.

Could also go in CHANGES.md, but probably not important enough.