Optimization of parts2.
Template for minheight problem.