Tidy up and document.