Added some stuff to clean memory