Fix some bugs in level editor