The mode variable was made global.