tweak a bunch of things to make more portable code