Buildfixes for el5 & el6

Sorry that this isn't more coherent, I tried to break the changes down into separate commits after the fact.