fix many bugs!