Cleaning the code and adding a version of translation using singletons instead of unsafe casting