Added some comments to the code. Still a more comprehensive documentation is needed.