Some changes to make it works properly after refactoring