Clean up/Factorize.