Refactored class name resolution.