Theory and simulations of free and supported metal nanoclusters and nanoalloys