Save CPU/Mem in sys state and fixed bug where stdout was being closed too early