Add a couple of helper scripts
Optimise code generation for array case statements
Fix an error introduced by the previous commit