Fixed bugs that could cause struct values not to be stored or misaligned

Change-Id: Ie36fe581c000fa4571c96fafd39a9e12fa29e1ca
Tested: on Linux