Out of memory warning, flash and RAM optimizations