Sheaf-theoretical methods in the solution of Kaplansky's problem