Fixes #138
Cherry picked Sen’s fix 5a03b0fea1bd9c5a2f79b7021154a07439066ccd
Fixes #141