Added leading semicolon
reorganized, using deferred for removing items only after items have been added