Fix issues #2220 and #2335