More code clean and minor tuning