Some memory improvements