Some changes and bug fixes