Fixes #2499 #2500 on master branch as well

Cant merge the branches via github UI, thus doing alignment manually.