Add changes from Nick's pull request