Fixed bugs when creating a new frame.