Clean up and add documentation