Merge pull request #1 from gianebao/master

Merge forked changes from gianbao
Fixes the non-removal of overlay on error.
Merge pull request #1 from boxuk/master

Fix overlay error by @rogerthomas.