Fixed some bugs and add some new methods in Optimizer class.