Fix issue #2012
Fix issue #2020
Fix issue #2021