fix some problems and red denotes todo