Minor cleanup, condensed some routines, mobed some parameters into modules.