Some refactoring and I18n improvements