Hack from https://stat.ethz.ch/pipermail/r-devel/2014-March/068448.html to address issue #186