Fix a ClassCastException

Hey, it's not an NPE this time.