Imported Tony's changes.