Fixed TNG memory alignment problem and reset pointers.
This is a temporary fix to the memory alignment problems on some
platforms. In the main TNG repository the whole I/O system is
rewritten to address this problem. This fix is to avoid the
problems without making too large changes.
There are also some pointers that were not reset after memory
was freed. This is also fixed in here.
This commit does not correspond to any commit in the TNG
repository.
Fixes #1542, #1546, #1547 and #1559.
Change-Id: I90a6406cccbc43fd57d4423c2b661019cf7763e8