Remove nasty switch statements

WARNING: This is completely untested (the index.html didn't work in my browser, probably some kind of config I have to set up)