adding documentation, and some minor fixes