Remove duplicated defs and reland #694.

Attempt to reland #694. Waiting for TravisCI