Reducing memory use. Adding memory profiler