Fixed issue #2009 and #2007