Some memory issues fixed