Added some comments, removed and added some debug information.