Implementation of the command pattern.