If you will search your site in google search and pass throught search result link you won't be redirected to correct language.
This is because at line 147 you check HTTP_REFERER with strpos function, and it returrn 108, because google store redirect address in url param.
I change this line
isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $_SERVER['SERVER_NAME'])
to
isset($_SERVER['HTTP_REFERER']) && preg_match('#http(?:s)?://'.$_SERVER['SERVER_NAME'].'#', $_SERVER['HTTP_REFERER'])
and now all looks work good.