added some functions and pragma pack for proper alignment