Cleanup and document somewhat.