Moved most commands into their own functions.