After the first version of the film was turned down by Mosfilm, Valentin Yezhov and Rustam Ibragimbekov were assigned to improve the script. Ibragimbekov was chosen by his nationality as an expert on the East, though in reality he was raised in Russia and never been in the region. A war veteran told Yezhov a story of a harem abandoned by a Basmachi leader on a run, which became the pivot of the new script. Further rewriting came from Motyl after he replaced Konchalovsky as director. Motyl completely reshaped and put forward the character of Vereschagin – all his dialogues, as well as about 60% of the entire script, were rewritten and improvised during the filming. Motyl also came up with the idea of revealing Sukhov's personality through his dreams, in which he writes letters to his beloved wife. Those letters were composed by Mark Zakharov, a friend of Motyl's.