Don't call getClass more than needed.