D.R.Y. and cleanup