fix many bugs.