Fixed #296
(cherry picked from commit fdfa433)