Added language guessing and small tweaks here and there