clean up

clean up the library, add comments, formatting