Update Issue 6

Backport to master

Fix to avoid hanging
(cherry picked from commit ba6c6c3b5c81c60e8f1019c4626f87bda8119d9c)
Update Issue 5

Backport to master

(cherry picked from commit c69eaa81b84d42e59daf1db100b0389021764266)