Added 3rd party minFunc code from Mark Schmidt