Added some comments and documentation