Fix rest removal function.