Add caching to avoid excessive use of reflection