Improve rank handling