Memory use improvement (thanks AJT)