Remove rough code
Add some optimization
Remove no longer needed code