Out of memory error - Trying to reduce some memory usage