Added weak references (Fixed some memory leaks)