Fixed memory leaks and release of textures

Change-Id: I8c0e78f07808b55c8cd5081ac85344912befafec
Removed dead code

Change-Id: I3f42ce77e460db2da06ed28e281a60793e09f296