Refactor code branches to map lookups
Refactor code branches to map lookups

This results in less complex code but I'm not sure about the performance impact of this.

MrJoy/surface_master,thomasjachmann/launchpad