Replaced huge elif statement with dictionary and functions

Large elif statements look messy and seem rather unpythonic to me, so I spent some downtime at work replacing it with a dictionary lookup for functions. Works exactly the same, though in theory should be slightly faster.

I won't mind if you prefer the elif statement though.