Fixed some bug. Need more test.
Some minor change