Add language support and small refactoring