Improved logic for schema class name detection.