[Olena-patches] 1800: Fix some memory management problems w.r.t. graph-based images.