Applying patch from zhangwenjie, thanks!