Added some comments and put all code in a namespace