structure unpacking and freeing
fix linux build errors
fix miscellaneous compile errors