Some bug fix after optimize