Fix for issues #2014 and partially #1815