Merged in patch to fix memory issue