A few tidyups and code rearranges.