ENH Fix some bugs