Fix some undefined bugs.