portability fixes (compiles under macosx 5.8 as well, probably on newer ones as well)