Add memory handling