Language refactoring

Extract languages map logic into a class. Added some tests