added method to cleanup weak references