Fix build on big endian architectures.
Fix small memory leaks on shutdown
Merge commit 'ef8cdd8' into merge3
Merge commit 'e81454f' into merge3