huge rewrite, split to base and yandex-specific parts