fix for Issue #1695 and #1652

Branch based on Tag atmosphere-project-2.2.0, because master was not compileable