Solve some bugs