General cleanup, and duplication removal.

@metadave