Some bugs fixed

Some bugs fixed