Cleaned up instrumentation code

Replaced a set of nested if statements with a single switch statement.