Added documentation and comments