Tune memory management better