General refactoring and i18n improvements