Fix bug + apply patch from original repo (commit 51d539366615dab483095efcb7ae69d946aa889b)