Fixing memory leaks, performance improvements resizing hash