Improved error handling

Don't restore error method prematurely, fix bug and make button unusable
for a short period after receiving an error.
Fix script cleanup