Added comments and debugging functions
Addded comments