Some changes and code refactor.