Piecewise optimal works, is a bit faster.  Fast enough?