Commuting elements and spaces of homomorphisms