fixing memory leak and repeated animation issues