fix many small legacy problem