Repair of some bugs