Bug fix and a few improve.