Fix reduce memory consumption