Mahmud looted libraries, museums and mosques in the interest of becoming rich.
Mahmud smashed the infidels' idols and destroyed their temples as he went, but was nonetheless cultured enough to use the booty to build a library, a museum, and a splendid mosque when he got back to Ghazni.