Update to remove duplicate code.

Untested.