For upstream

Here's a new PR. It has everything we discussed, cleaned up and fixed. I also force it to build 32 bits since I sometimes build on a 64 bit system and the results don't work right.