Some bugs fixed

Fix some bugs