OutOfMemory fix and performance