Added some bug fix.