Fixes some bugs (error in managing object references)