Fix potential bugs.