Added some documentation and comments