Cherry picked 1774efba106c759c3e741d1b4e90cfdc9a210e65 from crashey
Cleaned up fix for issue #4
fix build on Ubuntu by forcibly cleansing CFLAGS before running the build
Add more checks to isolate the bug
Merge branch 'master' into crashey