some cleanup, smaller functions