Add documentation, clean up tests