Some changes and bug fix