Fixes #2499 #2500 master
Merge pull request #2502 from Lineflyer/master

Fixes #2499 #2500 on master branch as well