Added documentation and fixes