Cleanup and add documentation