Fix for #3088.

Tested on OSX, Linux, Win 8.1