Added memory management functions