Fix many bugs found during full test.