Refactored this ugliness away.

Done.