Fixed issue which was causing 'out of memory' errors