Now it's a rather big nested switch statement, but at least it's all in one place now.
Attach a file by drag & drop or click to upload