Fixes #3145
Fixes #2815
Fixes #3146
Merge pull request #3155 from Zuhayr/master

Bug fixes.