Fix many bugs.