fixed merge and fix some bugs