Implementation of remove method.