Fix for #390. Thanks Stack Overflow.