Fixes #4240
Fixes #4151
Removing my debug changes.
Merge pull request #4243 from Zuhayr/master

Small fixes.