Fixed odd logic in give-cmd, added two more lines and fixed some bugs.