Several bug fix.