Added documentation and a few minor changes