Include cmd.h where needed and fix the errors.