add docs, and some small modifications