Some refactoring and references