Fixing bug when removing objects