IMPROVE: reuse previous allocated memory when reallocating for slight speedup. #15