Now deals properly with errors, and the code is tidied into wizards.js