repaired some bugs