changed to Eigen lib; fix some bugs