Fixed issue #1108 and #1112