Committing Dan's changes from his pull request.