Plugged the memory leak

Also added better note management
material transitions