Clean up and document somewhat.