Missing refactoring and bugfix