Minor changes to Paul's code.