add casts where necessary for warning avoidance
Merge branch 'master' into sid
fix up win32 build
propagate relevant build env vars