This closes #4040