lots of linux build (and portability, generally) fixes