Some bug fixs