Fixed issues #2304 and #2348