Resolve HashMap memory leaks

Fixed memory leaks in HashMap. Unfortunately, we did not use smart
pointers, so we had to use a less-elegant solution to delete key chains
in the HashMap involving using an additional list to store pointers to
everything that must be deleted upon deconstruction.