Changed ordering of linkage for zlib, and fixed memory error related to linkage with functions.