Fix warning about unused var when no libexpat.
fix access above array bounds
fix warnings in 64-bit builds