Added support for higher-order polynomial fitting.