Fixes bug that caused looping in petra and OOMs