Added documentation and in-line comments.