This closes #4001