improved translate-function

misc changes and fixes