Fix issues preventing build on Linux
Remerge with upstream
Merge pull request #1 from nohal/master

Fix issues preventing build on Linux