Add some function, and bug fix.