Bug 5260: simplify script and error handling