moving to new cstruct API and fixing code on macosx