fix many bugs and enhance user interface