math fixes and packed struct declarations updates