Addressed issues with low memory and malloc