Fixed #2306 and #2305.