Ugly hacks to get things working on Linux.  Don't use this version on other platforms.