Somewhat refactored translation code