Added some comment and fixes