Code cleanup (code copy/paste) through more generic functions.