Hashmap improvements, new memory functions and tests.
Fixes a memory leak in hashmap implementation.