Fixing memory leak in array values indefinitely being stored.