Language small refactor and fixes