added documentation and minor changes