Added documentation and added a few comments