clean up and add documentation