Fix memory cleanup for hash tables.
Fix buffer size error.
Fix for leak when overwriting cells in constant_memory mode.
Refactored tmpfile() usage for that it can be over-ridden.
Fix handling of NULL strings to the write() functions.
Fixed some unnecessary pointer checks.
Added safer string copy.