Added some comments and removed debug output.