Move CSS class finding logic into a class.